/**
 * Created by dev-001 on 2017/2/27.
 * 知识点
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const PointSchema = new Schema({
    name: String,
    childs: [{
        type: ObjectId,
        ref: 'Point'
    }],
    parentId: {
        type: ObjectId,
        ref: 'Point'
    },
    subject: {
        type: ObjectId,
        ref: 'Subject'
    },
    grade: {
        type: ObjectId,
        ref: 'Grade'//系统内置标准的的年级
    },
    lever: Number,//1初中，2高中
    createdAt: Date,
    updatedAt: Date
});

PointSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Point', PointSchema);